package com.ntv.persistent.wishes;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.ntv.domain.IWishes;
import com.ntv.domain.Wishes;
import com.ntv.persistent.util.DateHelper;

/**
 * @author Vedamoorthi Vairam
 * @since 11/01/2009
 *
 */
public class WishesMapper implements RowMapper {

	/* (non-Javadoc)
	 * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
	 */
	public Object mapRow(ResultSet rs, int arg1) throws SQLException
	{
		IWishes wishes = new Wishes();
		
		wishes.setCreatedBy(rs.getLong("created_by"));
		wishes.setCreatedDate(rs.getDate("created_date"));
		wishes.setFullnameWhoIs(rs.getString("fullname_who_is"));
		wishes.setFullnameWhomTo(rs.getString("fullname_whom_to"));
		
		wishes.setId(rs.getLong("id"));
		wishes.setImage(rs.getBinaryStream("image"));
		wishes.setMessage(rs.getString("message"));
		wishes.setNativePlace(rs.getString("native_place"));
		wishes.setSubject(rs.getString("subject"));
		wishes.setAuthorized(rs.getBoolean("is_authorized"));
		wishes.setContentId(rs.getLong("content_id"));
		
		
		wishes.setPublishDateString(DateHelper.getDateWithTime(rs.getTimestamp("publish_date")));
		
		return wishes;
	}
}
